// ============================================================================
//
// Copyright (C) 2006-2007 Dengues
//
// Google Group: http://groups.google.com/group/dengues
// QQ Group: 24885404
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
//
// ============================================================================
package org.dengues.commons.connectivity;

import org.dengues.commons.IDenguesSharedImage;
import org.dengues.commons.utils.ImageUtil;
import org.eclipse.swt.graphics.Image;

/**
 * Qiang.Zhang.Adolf@gmail.com class global comment. Detailled comment <br/>
 * 
 * $Id: Dengues.epf 2007-12-5 qiang.zhang $
 * 
 */
public enum EDatabaseType {

    MYSQL("MySQL", //$NON-NLS-1$
          Boolean.FALSE,
          ImageUtil.getImage(IDenguesSharedImage.PREFS_MYSQL),
          "jdbc:mysql://<host>:<port>/<sid>", //$NON-NLS-1$
          "3306", //$NON-NLS-1$
          "org.gjt.mm.mysql.Driver", //$NON-NLS-1$
          Boolean.TRUE,
          "org.hibernate.dialect.MySQLDialect"), //$NON-NLS-1$
    PSQL("PostgreSQL", //$NON-NLS-1$
         Boolean.TRUE,
         ImageUtil.getImage(IDenguesSharedImage.PREFS_PSQL),
         "jdbc:postgresql://<host>:<port>/<sid>", //$NON-NLS-1$
         "5432", //$NON-NLS-1$
         "org.postgresql.Driver", //$NON-NLS-1$
         Boolean.TRUE,
         "org.hibernate.dialect.PostgreSQLDialect"), //$NON-NLS-1$
    IBMDB2("DB2", //$NON-NLS-1$
           Boolean.FALSE,
           ImageUtil.getImage(IDenguesSharedImage.PREFS_DB2),
           "jdbc:db2://<host>:<port>/<sid>", //$NON-NLS-1$
           "50000", //$NON-NLS-1$
           "com.ibm.db2.jcc.DB2Driver", //$NON-NLS-1$
           Boolean.TRUE,
           "org.hibernate.dialect.DB2Dialect"), //$NON-NLS-1$
    INGRES("Ingres", //$NON-NLS-1$
           Boolean.FALSE,
           ImageUtil.getImage(IDenguesSharedImage.PREFS_INGRES),
           "jdbc:ingres://<host>:<port>/<sid>", //$NON-NLS-1$
           "II7", //$NON-NLS-1$
           "com.ingres.jdbc.IngresDriver", //$NON-NLS-1$
           Boolean.TRUE,
           "org.hibernate.dialect.IngresDialect"), //$NON-NLS-1$
    MSSQL("Microsoft SQL Server", //$NON-NLS-1$
          Boolean.FALSE,
          ImageUtil.getImage(IDenguesSharedImage.PREFS_MSSQL),
          "jdbc:jtds:sqlserver://<host>:<port>/<sid>", //$NON-NLS-1$
          "1433", //$NON-NLS-1$
          "net.sourceforge.jtds.jdbc.Driver", //$NON-NLS-1$
          Boolean.TRUE,
          "org.hibernate.dialect.SQLServerDialect"), //$NON-NLS-1$

    INFORMIX("Informix", //$NON-NLS-1$
             Boolean.FALSE,
             ImageUtil.getImage(IDenguesSharedImage.PREFS_INFORMIX),
             "jdbc:informix-sqli://<host>:<port>/<sid>:informixserver=<sid>", //$NON-NLS-1$
             "1", //$NON-NLS-1$
             "com.informix.jdbc.IfxDriver", //$NON-NLS-1$
             Boolean.TRUE,
             "org.hibernate.dialect.InformixDialect"), //$NON-NLS-1$
    ACCESS("Access", //$NON-NLS-1$
           Boolean.FALSE,
           ImageUtil.getImage(IDenguesSharedImage.PREFS_ACCESS),
           "jdbc:odbc:Driver={Microsoft Access Driver (*.mdb)};DBQ=<file>", //$NON-NLS-1$
           "0", //$NON-NLS-1$
           "sun.jdbc.odbc.JdbcOdbcDriver", //$NON-NLS-1$
           Boolean.FALSE,
           "org.hibernate.dialect.SQLServerDialect"), //$NON-NLS-1$
    // SQLITE(
    // "SQLite",
    // Boolean.FALSE,
    // ImageUtil.getImage(IDenguesSharedImage.PREFS_SQLITE),
    // "jdbc:sqlite:/<file>",
    // "0",
    // "org.sqlite.JDBC",
    // Boolean.FALSE,
    // "org.hibernate.dialect.SQLServerDialect"),
    GJDBC("Generic JDBC Driver", //$NON-NLS-1$
          Boolean.FALSE,
          ImageUtil.getImage(IDenguesSharedImage.PREFS_GJDBC),
          "jdbc:odbc:<sid>", //$NON-NLS-1$
          "0", //$NON-NLS-1$
          "sun.jdbc.odbc.JdbcOdbcDriver", //$NON-NLS-1$
          Boolean.TRUE,
          "org.hibernate.dialect.SQLServerDialect"), //$NON-NLS-1$
    AS400("AS400", //$NON-NLS-1$
          Boolean.FALSE,
          ImageUtil.getImage(IDenguesSharedImage.PREFS_AS400),
          "jdbc:as400://<host>/<sid>;prompt=false;libraries=<sid>", //$NON-NLS-1$
          "0", //$NON-NLS-1$
          "com.ibm.as400.access.AS400JDBCDriver", //$NON-NLS-1$
          Boolean.TRUE,
          "org.hibernate.dialect.DB2400Dialect"), //$NON-NLS-1$
    INTERBASE("Interbase", //$NON-NLS-1$
              Boolean.FALSE,
              ImageUtil.getImage(IDenguesSharedImage.PREFS_INTERBASE),
              "jdbc:interbase://<host>/<sid>", //$NON-NLS-1$
              "0", //$NON-NLS-1$
              "interbase.interclient.Driver", //$NON-NLS-1$
              Boolean.TRUE,
              "org.hibernate.dialect.InterbaseDialect"), //$NON-NLS-1$
    // TERADATA(
    // "Teradata",
    // Boolean.FALSE,
    // ImageUtil.getImage(IDenguesSharedImage.PREFS_TERADATA),
    // "jdbc:teradata://<host>/<sid>",
    // "0",
    // "com.ncr.teradata.TeraDriver",
    // Boolean.TRUE,
    // "org.hibernate.dialect.SQLServerDialect"),
    FIREBIRD("FireBird", //$NON-NLS-1$
             Boolean.FALSE,
             ImageUtil.getImage(IDenguesSharedImage.PREFS_FIREBRID),
             "jdbc:firebirdsql:<host>:<file>", //$NON-NLS-1$
             "0", //$NON-NLS-1$
             "org.firebirdsql.jdbc.FBDriver", //$NON-NLS-1$
             Boolean.TRUE,
             "org.hibernate.dialect.FirebirdDialect"), //$NON-NLS-1$

    ORACLE("Oracle", //$NON-NLS-1$
           Boolean.TRUE,
           ImageUtil.getImage(IDenguesSharedImage.PREFS_ORACLE),
           null,
           "-1", //$NON-NLS-1$
           "oracle.jdbc.driver.OracleDriver", //$NON-NLS-1$
           Boolean.TRUE,
           "org.hibernate.dialect.OracleDialect"), //$NON-NLS-1$
    SYBASE("Sybase", //$NON-NLS-1$
           Boolean.FALSE,
           ImageUtil.getImage(IDenguesSharedImage.PREFS_SYBASE),
           null,
           "-1", //$NON-NLS-1$
           "com.sybase.jdbc3.jdbc.SybDriver", //$NON-NLS-1$
           Boolean.TRUE,
           "org.hibernate.dialect.SybaseDialect"), //$NON-NLS-1$
    HSQLDB("HypersonicSQL", //$NON-NLS-1$
           Boolean.FALSE,
           ImageUtil.getImage(IDenguesSharedImage.PREFS_HSQLDB),
           null,
           "-1", //$NON-NLS-1$
           "org.hsqldb.jdbcDriver", //$NON-NLS-1$
           null,
           "org.hibernate.dialect.HSQLDialect"), //$NON-NLS-1$
    DERBY("Derby", //$NON-NLS-1$
          Boolean.FALSE,
          ImageUtil.getImage(IDenguesSharedImage.PREFS_DERBY),
          null,
          "-1", //$NON-NLS-1$
          null,
          null,
          "org.hibernate.dialect.SQLServerDialect"); //$NON-NLS-1$

    public final static String MARK_PORT = "<port>"; //$NON-NLS-1$

    public final static String MARK_HOST = "<host>"; //$NON-NLS-1$

    public final static String MARK_FILE = "<file>"; //$NON-NLS-1$

    public final static String MARK_SID = "<sid>"; //$NON-NLS-1$

    public final static String MARK_ROOTPATH = "<rootPath>"; //$NON-NLS-1$

    // displayName is used in Java code.
    private String displayName;

    private Boolean isNeedSchema;

    /**
     * Qiang.Zhang.Adolf@gmail.com Comment method "getDisplayName".
     * 
     * @return
     */
    public String getDisplayName() {
        return this.displayName;
    }

    /**
     * Qiang.Zhang.Adolf@gmail.com Comment method "isNeedSchema".
     * 
     * @return
     */
    public Boolean isNeedSchema() {
        return this.isNeedSchema;
    }

    private Image image;

    private String url;

    private String port;

    private String driver;

    private Boolean isNeedUser;

    private String dialect;

    /**
     * Qiang.Zhang.Adolf@gmail.com EDatabaseType constructor comment.
     * 
     * @param displayName
     * @param isNeedSchema
     * @param image
     * @param url
     * @param port
     * @param driver
     * @param isNeedUser
     * @param dialect
     */
    EDatabaseType(String displayName, Boolean isNeedSchema, Image image, String url, String port, String driver,
            Boolean isNeedUser, String dialect) {
        this.displayName = displayName;
        this.isNeedSchema = isNeedSchema;
        this.image = image;
        this.url = url;
        this.port = port;
        this.driver = driver;
        this.isNeedUser = isNeedUser;
        this.dialect = dialect;
    }

    /**
     * Qiang.Zhang.Adolf@gmail.com Comment method "getTypeFromDisplayName".
     * 
     * @param displayName
     * @return
     */
    public static EDatabaseType getTypeFromDisplayName(String displayName) {
        for (EDatabaseType typename : EDatabaseType.values()) {
            if (typename.getDisplayName().equals(displayName)) {
                return typename;
            }
        }
        return GJDBC;
    }

    /**
     * Getter for image.
     * 
     * @return the image
     */
    public Image getImage() {
        return this.image;
    }

    /**
     * Qiang.Zhang.Adolf@gmail.com Comment method "getUrl".
     * 
     * @return
     */
    public String getUrl() {
        return this.url;
    }

    /**
     * Qiang.Zhang.Adolf@gmail.com Comment method "getPort".
     * 
     * @return
     */
    public String getPort() {
        return this.port;
    }

    /**
     * Qiang.Zhang.Adolf@gmail.com Comment method "getDriver".
     * 
     * @return
     */
    public String getDriver() {
        return this.driver;
    }

    /**
     * Getter for isNeedUser.
     * 
     * @return the isNeedUser
     */
    public Boolean isNeedUser() {
        return this.isNeedUser;
    }

    /**
     * Getter for dialect.
     * 
     * @return the dialect
     */
    public String getDialect() {
        return this.dialect;
    }

}
